import { _findcar } from '../../common/parking'
const app = getApp()
Page({
  data: {
    carNo: '',
    detail: null
  },
  findCar () {
    app.loading('加载中')
    const { carNo } = this.data
    _findcar(carNo).then(res => {
      wx.hideLoading()
      console.log(res)
      if (res.data.IsSuccess) {
        let detail = res.data.Data
        detail.image_data = 'data:image/png;base64,' + detail.image_data
        this.setData({
          detail
        })
      } else {
        wx.showModal({
          title: '对不起',
          content: res.data.Msg,
          showCancel: false,
          success: r => {
            wx.navigateBack()
          }
        })
      }
    }).catch(err => {
      wx.hideLoading()
      console.log(err)
      wx.showModal({
        title: '对不起',
        content: JSON.stringify(err),
        showCancel: false
      })
    })
  },
  onLoad (options) {
    this.data.carNo = options.num
    this.setData({
      carNo: this.data.carNo
    })
    this.findCar()
  },
  onReady () {},
  onShow() {
    app.memberReadyCb = () => {
    }
    app.fansReadyCb = () => {
      // app.checkMember()
    }
    app.init()
  },
  onShareAppMessage() {
    return app.shareInfo
  }
})